package com.kyh.util.sys;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.kyh.entity.base.BaseEntity;

public class OptionUtil extends BaseEntity {
	
	public static JSONObject optionToSelect(Map<String, Object> option) {
		JSONObject JO = new JSONObject();
		JO.put("value", option.get("optionValue"));
		JO.put("text", option.get("optionName"));
		return JO;
	}
	
	public static JSONArray arrSelect(List<Map<String, Object>> listEntity) {
		JSONArray JA = new JSONArray();
		for (Map<String, Object> option : listEntity) {
			JA.add(optionToSelect(option));
		}
		return JA;
	}
	
	public static Map<String, Object> toMap(List<Map<String, Object>> listEntity) {
		Map<String, Object> map = new HashMap<String, Object>();
		for (Map<String, Object> option : listEntity) {
			map.put(option.get("optionValue").toString(), option.get("optionName"));
		}
		return map;
	}
}